# RUN: tf-mlir-translate -graphdef-to-mlir -tf-enable-shape-inference-on-import=false %s -tf-graph-as-function -tf-control-output-arrays=assign_variable | tf-mlir-translate -mlir-tf-graph-to-hlo-text -tf-input-shapes=2:2 -tf-input-data-types=DT_FLOAT,DT_FLOAT -tf-xla-input-types=parameter,resource -tf-xla-emit-return-tuple | FileCheck %s

node {
  name: "arg0"
  op: "_Arg"
  attr {
    key: "T"
    value {
      type: DT_FLOAT
    }
  }
  attr {
    key: "index"
    value {
      i: 0
    }
  }
}
node {
  name: "arg1"
  op: "_Arg"
  attr {
    key: "T"
    value {
      type: DT_RESOURCE
    }
  }
  attr {
    key: "index"
    value {
      i: 1
    }
  }
}
node {
  name: "assign_variable"
  op: "AssignVariableOp"
  input: "arg1"
  input: "arg0"
  attr {
    key: "dtype"
    value {
      type: DT_FLOAT
    }
  }
}
library {
}
versions {
  producer: 511
}

# Tests a conversion from Graph to MLIR with resource arguments.

# CHECK-LABEL: HloModule main, input_output_alias={ {0}: (1, {}, may-alias) }
# CHECK:       ENTRY %main.{{[0-9]+}} ([[ARG0:.*]]: f32[2], [[ARG1:.*]]: f32[2]) -> (f32[2]) {
# CHECK-NEXT:    %[[ARG1]] = f32[2]{0} parameter(1)
# CHECK-NEXT:    %[[ARG0]] = f32[2]{0} parameter(0)
# CHECK-NEXT:    ROOT %tuple.{{[0-9]+}} = (f32[2]{0}) tuple(f32[2]{0} %[[ARG0]])
# CHECK-NEXT:  }

# CHECK:       // InputMapping {0, 1}
# CHECK-NEXT:  // XlaInputShape f32[2]
# CHECK-NEXT:  // XlaInputShape f32[2]
# CHECK-NEXT:  // XlaOutputShape (f32[2])
# CHECK-NEXT:  // ResourceUpdate input_index=1 type=float shape=(2) modified
